package achi.community.irla.icefaces;

import com.icesoft.faces.component.dragdrop.DndEvent;
import com.icesoft.faces.component.dragdrop.DragEvent;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;

/**
 * <p>The DragDropBean handles DragEvent listeners for the
 * Drag and Drop tutorial.</p>
 */
@ManagedBean
@SessionScoped //@RequestScoped
public class DragDrop {

	private String dragMessage = "";
	private String dropValue = "";

        private String target = "";
        private String done = "";
		
	public void dragListener(DragEvent dragEvent){
	       // dragMessage += DragEvent.getEventName(dragEvent.getEventType()) + ", ";
	        
	        if (dragEvent.getEventType() == DndEvent.DROPPED){
	        	dropValue = (String) dragEvent.getTargetDropValue();
                        if(dropValue.equals("Targeted Achievement")){
                            target = "<img src=120px-Face-smile.svg.png>";
                            done = "";
                        }
                        else if(dropValue.equals("Done Achievement")){
                            done = "<img src='120px-Face-smile.svg.png'/>";
                            target = "";
                        }
                        else{
                            done = "";
                            target = "";
                        }
                }
                dragMessage = "dropValue:#"+dropValue+"# "+done+":#"+done+"# target:#"+target+"#";
	}

	public String getDropValue () {
            return dropValue;
	}
	
	public String getDragMessage () {
            return dragMessage;
	}

        public boolean isTargetFilled(){
            return !target.equals("");
        }

        public boolean isDoneFilled(){
            return !done.equals("");
        }

        public String getTarget(){
            return target;
        }

        public String getDone(){
            return done;
        }
}
